package com.gf.fund.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.gf.common.util.DateFormater;
import com.gf.fund.model.Fund;


public class FundMapper implements RowMapper<Fund>{

	private static String COLUME_ID="id";
	private static String COLUME_USERID="userId";
	private static String COLUME_LAST="last";
	private static String COLUME_CHANGES="changes";
	private static String COLUME_TOTAL="total";
	private static String COLUME_CREATETIME="createTime";
	private static String COLUME_EVENT="event";
	private final static FundMapper MAPPER = new FundMapper();

	public final static FundMapper getMapper() {
		return MAPPER;
	}
	@Override
	public Fund mapRow(ResultSet set, int row) throws SQLException {
		Fund fund = new Fund();
		fund.setEvent(set.getString(COLUME_EVENT));
		fund.setId(set.getLong(COLUME_ID));
		fund.setUserId(set.getLong(COLUME_USERID));
		fund.setLast(set.getDouble(COLUME_LAST));
		fund.setChanges(set.getDouble(COLUME_CHANGES));
		fund.setTotal(set.getDouble(COLUME_TOTAL));
		fund.setCreateTime(set.getTimestamp(COLUME_CREATETIME));
		fund.setCreateTimeString(DateFormater.changeToString(set.getTimestamp(COLUME_CREATETIME), "yyyy-MM-dd HH:mm"));
		return fund;
	}

}
